#ifndef __GKOS_SYNC_H
#define __GKOS_SYNC_H

#include "lib/ds/list.h"
#include "lib/global.h"
#include "thread/thread.h"

// 信号量
struct semaphore {
    uint8_t value;
    struct list wait_list;
};

// 锁
struct lock {
    struct task_pcb *holder;
    struct semaphore semaphore;
    // 重复次数
    uint32_t holder_repeat_count;
};

void sema_init(struct semaphore *sema, uint8_t value);
void sema_down(struct semaphore *sema);
void sema_up(struct semaphore *sema);
void lock_init(struct lock *lock);
void lock_acquire(struct lock *lock);
void lock_release(struct lock *lock);


#endif